package cc.rboot.inject.template;

import cc.rboot.inject.annotation.InjectBody;
import cc.rboot.inject.annotation.InjectSetter;
import cc.rboot.inject.core.AbstractMapperInjector;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

@RestController
@RequestMapping(path = "/_inject")
public class InjectPost<T> extends AbstractMapperInjector<T> {


    /**
     * 默认的新增接口
     *
     * @param entity
     * @return
     */
    @InjectSetter
    @PostMapping
    public T _execute(@Validated @InjectBody T entity) throws Exception {
        super.getService().save(entity);
        return entity;
    }
}
